-
Notifications
You must be signed in to change notification settings - Fork 8.3k
drivers: display: ssd16xx: implement display_set_orientation #73360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers: display: ssd16xx: implement display_set_orientation #73360
Conversation
|
Hello @Snevzor, and thank you very much for your first pull request to the Zephyr project! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default needs justification
https://docs.zephyrproject.org/latest/build/dts/bindings-upstream.html#rules-for-default-values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for checking and pointing out @decsny. I looked at existing bindings to not re-invent the wheel. This example also lacks the justification: https://github.com/zephyrproject-rtos/zephyr/blob/main/dts/bindings/display/ilitek%2Cili9xxx-common.yaml#L23
I really struggle to find a good justification as a description for this. It does not correspond to default values after reset, nor is it a manufacturer recommendation.
The default makes sense for when not interested in the rotation property, and it helps to avoid breaking existing sdd16xx usages.
Can you help find a suitable description? Or do I need to remove the default if it is not possible to give a good justification?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can say rotation is off by default, for properties like this where one of the values corresponds to some kind of "none" meaning. The binding you linked is wrong for not clarifying this. Since you found it, please add a commit to fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the excellent suggestion. I've updated this and added a commit for ili9xxx.
This is not required and not acceptable, coding style is perfectly fine. |
|
re-opening after inappropriate closure |
faxe1008
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in the LVGL gluecode look ok but they are independent of the changes done in this pull request. They are simply there to make LVGL of the hardware rotation. (Note that this still does not allow for runtime rotation since the capabilities struct would need to be refetched upon rotation change).
In general it would be preferable to have pretty much atomic pull requests that only touch as much code as they need to. This involves not doing reformatting commits. Can you maybe adjust this PR to only add the rotation without the reformatting and open another PR for the LVGL code? The simpler you keep the pull requests the easier it is to get them reviewed and merged succesfully :^)
I chose this approach instead of software rotation because I need it for an ultra low power project. Rotation in steps of 0, 90, 180, 270 degrees is done by changing the data entry modes. This commit removes the orientation-flipped property as it is redundant. I made the assumption that the current driver implementation is right about controller X/Y versus display width/height. The display controller X parameter matches with the display height (dts) and display controller Y parameter matches with the display width (dts). It looks like display manufacturers choose to have it like this because a wider screen probably makes more sense. Tested on the reel_board with a 250x122 display (ssd1673 controller) and a custom PCB with a 200x200 display (ssd1681 controller). Also tested all orientations with various width/height dts overrides. Signed-off-by: Sven Depoorter <[email protected]>
The driver writes the scan entry mode to the display controller on each set_window call. Multiple calls to set_window can be needed to update a single frame buffer in the controller. There's a performance improvement by only setting the scan mode when the orientation is changed (set_orientation, see previous commit) and when the profile has changed. For the latter the scan_mode is lost on the controller due to a software reset. Signed-off-by: Sven Depoorter <[email protected]>
To align with udpated ssd16xx bindings. Signed-off-by: Sven Depoorter <[email protected]>
ce38351 to
93b5d12
Compare
|
@jfischer-no and @faxe1008, the formatting commit has been dropped. Your input is welcome at #73465 |
decsny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approving DT bindings
|
@brgl @faxe1008 @fabiobaltieri @jfischer-no can we get a review on the code? Thanks! |
| x_start = x / SSD16XX_PIXELS_PER_BYTE; | ||
| x_end = (x + desc->width - 1) / SSD16XX_PIXELS_PER_BYTE; | ||
| y_start = y; | ||
| y_end = (y + desc->height - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need to write the scan_mode here, since we do it within the set_orientation function? IE will the scan mode setting persist between display frames, or does it need to be set every time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing @danieldegrasse!
In the second commit I removed writing the scan_mode on each set_window call because I didn't find any indication in the datasheet that this should not persist between resets. So I tested it with the two mentioned display controllers and it worked so that seems to prove that the scan_mode indeed persists between display frames.
Because there is a software reset in the set_profile function I also added writing the scan_mode over there.
I do wonder why it was added to the set_window function in the first place instead of in the controller_init so I completely understand your doubts.
If anyone with a ssd16xx laying around could double check this, that would be great.
@andysan, I see you have made some amazing improvements to this driver in the past, would you mind checking this as well?
|
@danieldegrasse please take a look |
|
@Snevzor when I run the display sample with this PR, I see logs like the following if I attempt to set the orientation to 90 degree rotation: Given that the display sample works with rotation on other displays (such as ili9xxx based ones) I think we should target enabling this sample here as well, to make sure the API usage between each display is consistent when rotation is applied.
Does this imply that the display sample would need to change to accommodate the rotation setting? |
|
@danieldegrasse thanks again for your review, testing, and patience. This is much appreciated. You are responding to the parts I found most challenging, which is good! The reason these are challenging is that there seems to be a larger issue existing already. Display drivers with rotation support (there aren't that many) that switch x/y resolution parameters in Display drivers with rotation support that don't switch x/y resolution parameters: There is also another open PR for adding rotation to st7789v (#72107). I've expressed my confusion about switching the parameters in this comment: #72107 (comment) I cannot test, but I would think that hw rotation with gc9x01x and ili9xxx together with LVGL will break when the LVGL glue code is updated. I'm a little confused about "the display sample". Which one exactly?
P.S. Our time zone difference makes for a very slow conversation. It must be especially hard for you because of the multiple context switches. Also, I'm leaving on holiday from 4 to 18 June, so this might get stuck then. But I'd rather have this PR stay open until every issue around display rotation is resolved than having it merged ASAP. It's for a hobby project, and I can work with my own patches until this gets resolved. |
Makes sense. I think we need to determine what makes the most sense here from the API perspective. Currently we have sort of left it up to the implementers which method a driver should use when performing rotation. Personally, I'm partial to expecting the application to swap the X/Y coordinates, since this is what LVGL does already. @faxe1008 what are your thoughts here?
My apologies, I'm referring to |
Wow, I wasn't even aware of that sample :p It makes sense that if this is to be used as ground truth for the API that rotation support should be fully added. Preferably it should act as LVGL does because I assume LVGL is the most used display subsystem. |
I agree with you 👍 . No matter which method is preferred (swapping resolutions vs. not) you always need the triplet of The orientation of the display should serve as a guideline to any renderer how the content will be presented to the user. The rendering framework/method needs to accommodate for it (bounds checking, buffer management etc.). Also, what I am thinking about is if maybe having set_orientation work in the Btw: @Snevzor thanks for splitting the PR up and bringing attention to this, code change wise this PR looks good imo. But since I do not own a display for that compatible to check and test the behavior I am hesitant on +1 this one :^) |
I agree that implementing this API in the SDL driver is the way to go- that can be used as a "ground truth" for how the driver should behave. My concern is that we have some technical debt here already- since we have display drivers behaving both ways in tree, there are likely downstream users relying on one behavior versus the other. As far as this PR, I think it is ok to merge as is (since the issue here is broader than this specific driver), but I think after 3.7 we should do the following:
I suggest making these changes after 3.7 because the time window until feature freeze is already rather tight- if you feel it would be better to try and standardize this before 3.7, I am open to trying but might need help converting/testing all display drivers in time. What are your thoughts here? |
|
@danieldegrasse can you give a +1 on this one or do we need another reviewer? |
I'm good with the changes given the nebulous state of how |
|
Hi @Snevzor! To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge. Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁 |
Yeah I think this is a post 3.7 change, the time window is too tight imo. |
I chose this approach instead of software rotation because I need it for an ultra low power project.
Rotation in steps of 0, 90, 180, 270 degrees is done by changing
the data entry modes.
This PR removes the orientation-flipped property, as it is redundant.
There's also a performance improvement in a separate commit.
Tested on the reel_board with a 250x122 display (ssd1673 controller)
and a custom PCB with a 200x200 display (ssd1681 controller).
Also tested all orientations with various width/height dts overrides.
To test with the LVGL sample, I had to change some glue code as well, see #73474